package com.atguigu.shardingjdbcdemo.mapper;

import com.atguigu.shardingjdbcdemo.entity.Order;
import com.atguigu.shardingjdbcdemo.vo.OrderVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderMapper extends BaseMapper<Order> {

    // 这里要使用逻辑表名
    @Select({"select o.order_no,sum(i.price * i.count) AS amount\n" +
            "from t_order o join t_order_item i on o.order_no = i.order_no\n" +
            "group by o.order_no; "})
    List<OrderVo> getOrderAmount();
}
